﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.Revit;
using YJKRevitView;
using YJKCopyModel.ColumnTransModel;
using YJKCopyModel.YJKRevitWndr;
using YJKCopyModel.Forms;
using YJKCopyModel.InteractiveOperation;
using YJKCopyModel.TransformWall;

namespace YJKCopyModel.CommonTrans
{
	public class QuickModelMainRequestMaker : InteractiveOperationBase
	{
		public override bool IfBreak
		{
			get
			{
				return true;
			}
		}

		public override void CloseFrom()
		{
		}

		public QuickModelMainRequestMaker(ExternalCommandData useExternalCommandData) : base(useExternalCommandData)
		{
			this.m_doc = useExternalCommandData.Application.ActiveUIDocument.Document;
			this.m_lstRequest = new List<InputRequest>();
			this.m_lstWallInfo = new List<CurveInfo>();
			this.m_lstColumnInfo = new List<CurveInfo>();
			this.m_lstWindowInfo = new List<DoorAndWindowBlockRefInfo>();
			this.m_lstWindowNumberInfo = new List<TextInfo>();
			this.m_lstWallCategory = new List<Category>();
			this.m_lstColumnCategory = new List<Category>();
			this.m_lstWindowCategory = new List<Category>();
			this.m_lstWindowNumberCategory = new List<Category>();
		}

		public override List<InputRequest> GetAllInputRequest()
		{
			return this.m_lstRequest;
		}

		public override void PrepareRequest()
		{
			CmdViewType types = (CmdViewType)13;
			bool flag = SwitchView.SetUsableView(types, this.m_useExternalCommandData) > 0;
			if (flag)
			{
				this.m_bCancel = true;
			}
			else
			{
				this.m_bCancel = false;
				SelecteEntType selectType = SelecteEntType.eLine | SelecteEntType.eArc | SelecteEntType.ePolyLine;
				SelecteEntType selectType2 = SelecteEntType.eLine | SelecteEntType.eArc | SelecteEntType.ePolyLine;
				QuickModelMainForm quickModelMainForm = new QuickModelMainForm(this);
				this.m_lstWallInfo = this.SearchImportDwgCurve(quickModelMainForm.WallLayers, selectType, this.m_lstWallCategory);
				this.m_lstColumnInfo = this.SearchImportDwgCurve(quickModelMainForm.ColumnLayers, selectType2, this.m_lstColumnCategory);
				this.m_lstWindowInfo = this.SearchImportDwgBlock(quickModelMainForm.WindowLayers, this.m_lstWindowCategory);
				this.m_lstWindowNumberInfo = this.SearchImportDwgText(quickModelMainForm.WindowNumberLayers, this.m_lstWindowNumberCategory);
				for (;;)
				{
					bool flag2 = quickModelMainForm.ShowDialog(this.m_handleRevit) != DialogResult.OK;
					if (flag2)
					{
						break;
					}
					List<string> list = new List<string>();
					List<Category> list2 = new List<Category>();
					bool flag3 = quickModelMainForm.DlgCloseType == QuickModelMainForm.CloseDlgType.RT_SetupParam;
					if (flag3)
					{
						new QuickModelSetupForm
						{
							Owner = quickModelMainForm
						}.ShowDialog();
					}
					else
					{
						bool flag4 = quickModelMainForm.DlgCloseType == QuickModelMainForm.CloseDlgType.RT_SelectWallLine;
						if (flag4)
						{
							List<CurveInfo> list3 = this.SelectImportDwgCurve(selectType, "请选择链接dwg图中的墙线", list, list2);
							bool flag5 = list3 != null && list3.Count > 0;
							if (flag5)
							{
								this.m_lstWallInfo.AddRange(list3);
								for (int i = 0; i < list.Count; i++)
								{
									bool flag6 = quickModelMainForm.AddWallLayer(list[i]);
									if (flag6)
									{
										this.m_lstWallCategory.Add(list2[i]);
									}
								}
							}
						}
						else
						{
							bool flag7 = quickModelMainForm.DlgCloseType == QuickModelMainForm.CloseDlgType.RT_SelectColumnLine;
							if (flag7)
							{
								List<CurveInfo> list4 = this.SelectImportDwgCurve(selectType2, "请选择链接dwg图中的柱边线", list, list2);
								bool flag8 = list4 != null && list4.Count > 0;
								if (flag8)
								{
									this.m_lstColumnInfo.AddRange(list4);
									for (int j = 0; j < list.Count; j++)
									{
										bool flag9 = quickModelMainForm.AddColumnLayer(list[j]);
										if (flag9)
										{
											this.m_lstColumnCategory.Add(list2[j]);
										}
									}
								}
							}
							else
							{
								bool flag10 = quickModelMainForm.DlgCloseType == QuickModelMainForm.CloseDlgType.RT_SelectWindow;
								if (flag10)
								{
									List<DoorAndWindowBlockRefInfo> list5 = this.SelectImportDwgBlock("请选择链接dwg图中的门窗边线", list, list2);
									bool flag11 = list5 != null && list5.Count > 0;
									if (flag11)
									{
										this.m_lstWindowInfo.AddRange(list5);
										for (int k = 0; k < list.Count; k++)
										{
											bool flag12 = quickModelMainForm.AddWindowLayer(list[k]);
											if (flag12)
											{
												this.m_lstWindowCategory.Add(list2[k]);
											}
										}
									}
								}
								else
								{
									bool flag13 = quickModelMainForm.DlgCloseType == QuickModelMainForm.CloseDlgType.RT_SelectWindowNumber;
									if (!flag13)
									{
										goto IL_37E;
									}
									List<TextInfo> list6 = this.SelectImportDwgText("请选择链接dwg图中的门窗编号", list, list2);
									bool flag14 = list6 != null && list6.Count > 0;
									if (flag14)
									{
										this.m_lstWindowNumberInfo.AddRange(list6);
										for (int l = 0; l < list.Count; l++)
										{
											bool flag15 = quickModelMainForm.AddWindowNumberLayer(list[l]);
											if (flag15)
											{
												this.m_lstWindowNumberCategory.Add(list2[l]);
											}
										}
									}
								}
							}
						}
					}
				}
				this.m_bCancel = true;
				this.ShowSelectLayeies();
				return;
				IL_37E:
				bool flag16 = quickModelMainForm.DlgCloseType == QuickModelMainForm.CloseDlgType.RT_TransForLevel;
				if (flag16)
				{
					this.ShowSelectLayeies();
					this.QuickModelLevelTrans(quickModelMainForm.WallLayers, quickModelMainForm.ColumnLayers, quickModelMainForm.WindowLayers, quickModelMainForm.WindowNumberLayers);
				}
				else
				{
					bool flag17 = quickModelMainForm.DlgCloseType == QuickModelMainForm.CloseDlgType.RT_TransForLocal;
					if (flag17)
					{
						this.ShowSelectLayeies();
						this.QuickModelLocalTrans(quickModelMainForm.WallLayers, quickModelMainForm.ColumnLayers, quickModelMainForm.WindowLayers, quickModelMainForm.WindowNumberLayers);
					}
					else
					{
						this.m_bCancel = true;
						this.ShowSelectLayeies();
					}
				}
			}
		}

		public void ClearSelectedWall()
		{
			Transaction transaction = new Transaction(this.m_doc);
			transaction.Start("ShowLayer");
			try
			{
				foreach (Category category in this.m_lstWallCategory)
				{
					this.m_doc.ActiveView.HYSetVisibility(category, true);
				}
			}
			catch
			{
			}
			transaction.Commit();
			this.m_lstWallInfo.Clear();
			this.m_lstWallCategory.Clear();
		}

		public void ClearSelectedColumn()
		{
			Transaction transaction = new Transaction(this.m_doc);
			transaction.Start("ShowLayer");
			try
			{
				foreach (Category category in this.m_lstColumnCategory)
				{
					this.m_doc.ActiveView.HYSetVisibility(category, true);
				}
			}
			catch
			{
			}
			transaction.Commit();
			this.m_lstColumnInfo.Clear();
			this.m_lstColumnCategory.Clear();
		}

		public void ClearSelectedWindow()
		{
			Transaction transaction = new Transaction(this.m_doc);
			transaction.Start("ShowLayer");
			try
			{
				foreach (Category category in this.m_lstWindowCategory)
				{
					this.m_doc.ActiveView.HYSetVisibility(category, true);
				}
			}
			catch
			{
			}
			transaction.Commit();
			this.m_lstWindowInfo.Clear();
			this.m_lstWindowCategory.Clear();
		}

		public void ClearSelectedWindowNumber()
		{
			Transaction transaction = new Transaction(this.m_doc);
			transaction.Start("ShowLayer");
			try
			{
				foreach (Category category in this.m_lstWindowNumberCategory)
				{
					this.m_doc.ActiveView.HYSetVisibility(category, true);
				}
			}
			catch
			{
			}
			transaction.Commit();
			this.m_lstWindowNumberInfo.Clear();
			this.m_lstWindowNumberCategory.Clear();
		}

		private void ShowSelectLayeies()
		{
			Transaction transaction = new Transaction(this.m_doc);
			transaction.Start("ShowLayer");
			try
			{
				while (this.m_lstWallCategory.Count > 0)
				{
					this.m_doc.ActiveView.HYSetVisibility(this.m_lstWallCategory[0], true);
					this.m_lstWallCategory.RemoveAt(0);
				}
				while (this.m_lstColumnCategory.Count > 0)
				{
					this.m_doc.ActiveView.HYSetVisibility(this.m_lstColumnCategory[0], true);
					this.m_lstColumnCategory.RemoveAt(0);
				}
				while (this.m_lstWindowCategory.Count > 0)
				{
					this.m_doc.ActiveView.HYSetVisibility(this.m_lstWindowCategory[0], true);
					this.m_lstWindowCategory.RemoveAt(0);
				}
				while (this.m_lstWindowNumberCategory.Count > 0)
				{
					this.m_doc.ActiveView.HYSetVisibility(this.m_lstWindowNumberCategory[0], true);
					this.m_lstWindowNumberCategory.RemoveAt(0);
				}
			}
			catch
			{
			}
			transaction.Commit();
		}

		private void QuickModelLevelTrans(List<string> lstWallLayer, List<string> lstColumnLayer, List<string> lstWindowLayer, List<string> lstWindowNumberLayer)
		{
			List<ICadElement> list = new List<ICadElement>();
			list.AddRange(this.m_lstWallInfo);
			list.AddRange(this.m_lstColumnInfo);
			list.AddRange(this.m_lstWindowInfo);
			list.AddRange(this.m_lstWindowNumberInfo);
			this.QuickModelTrans(list, lstWallLayer, lstColumnLayer, lstWindowLayer, lstWindowNumberLayer);
		}

		private void QuickModelLocalTrans(List<string> lstWallLayer, List<string> lstColumnLayer, List<string> lstWindowLayer, List<string> lstWindowNumberLayer)
		{
			List<ICadElement> list = new List<ICadElement>();
			list.AddRange(this.m_lstWallInfo);
			list.AddRange(this.m_lstColumnInfo);
			list.AddRange(this.m_lstWindowInfo);
			list.AddRange(this.m_lstWindowNumberInfo);
			List<ICadElement> list2 = new List<ICadElement>();
			DelegateInRange<ICadElement> delegateInRange = new DelegateInRange<ICadElement>(RevitCommonFunctions.IsElementInBox);
			try
			{
				while (list2.Count < 1)
				{
					this.m_dwgEntitiesSelection.TryGetEntitesInPickBox<ICadElement>(out list2, list, delegateInRange, "请框选识别范围");
				}
			}
			catch
			{
				this.m_bCancel = true;
				return;
			}
			this.QuickModelTrans(list2, lstWallLayer, lstColumnLayer, lstWindowLayer, lstWindowNumberLayer);
		}

		private void QuickModelTrans(List<ICadElement> lstCadElemInfo, List<string> lstWallLayer, List<string> lstColumnLayer, List<string> lstWindowLayer, List<string> lstWindowNumberLayer)
		{
			bool flag = lstCadElemInfo == null || lstCadElemInfo.Count < 1;
			if (flag)
			{
				YJKMessageBox.Show("没有选择要翻模的图元！");
				this.m_bCancel = true;
			}
			else
			{
				QuickModelProgressBar quickModelProgressBar = new QuickModelProgressBar("正在识别...");
				quickModelProgressBar.Show();
				QuickModelSetupForm quickModelSetupForm = new QuickModelSetupForm();
				double dMinLen = AssistFunc.mmToFeet((double)quickModelSetupForm.MinWallLength);
				double dMinWidth = AssistFunc.mmToFeet((double)quickModelSetupForm.MinWallWidth);
				double dMaxWidth = AssistFunc.mmToFeet((double)quickModelSetupForm.MaxWallWidth);
				List<Curve> windowBaseCurves = WallManager.GetWindowBaseCurves(lstCadElemInfo, lstWindowLayer);
				quickModelProgressBar.RefreshProgressBarText("正在识别墙...");
				quickModelProgressBar.SetSubMaxValue(lstWallLayer.Count * 9 + 1);
				List<DoubleParaleCurve> list = new List<DoubleParaleCurve>();
				foreach (string strWallLayer in lstWallLayer)
				{
					bool isDisposed = quickModelProgressBar.IsDisposed;
					if (isDisposed)
					{
						break;
					}
					quickModelProgressBar.RefreshProgressBar("正在识别墙...");
					List<Curve> wallBorderCurves = WallManager.GetWallBorderCurves(lstCadElemInfo, strWallLayer);
					List<DoubleParaleCurve> wallCurves = DoubleCurveManager.GetWallCurves(wallBorderCurves, windowBaseCurves, quickModelProgressBar, dMaxWidth, dMinWidth, dMinLen);
					list.AddRange(wallCurves);
				}
				bool isDisposed2 = quickModelProgressBar.IsDisposed;
				if (isDisposed2)
				{
					this.m_bCancel = true;
				}
				else
				{
					quickModelProgressBar.RefreshProgressBarText("正在识别柱...");
					quickModelProgressBar.SetSubMaxValue(2);
					List<CurveInfo> lstAllCurve = new List<CurveInfo>();
					lstAllCurve = lstCadElemInfo.FindAll((ICadElement item) => item is CurveInfo).ToList<ICadElement>().ConvertAll<CurveInfo>((ICadElement item) => item as CurveInfo);
					Dictionary<ColumnConfigInfo, List<ColumnLoopInfo>> dictionary = ColumnManager.GroupColumn(lstAllCurve, lstColumnLayer);
					bool isDisposed3 = quickModelProgressBar.IsDisposed;
					if (isDisposed3)
					{
						this.m_bCancel = true;
					}
					else
					{
						quickModelProgressBar.RefreshProgressBarText("正在识别门窗...");
						quickModelProgressBar.SetSubMaxValue(2);
						List<ICadElement> list2 = lstCadElemInfo.FindAll((ICadElement thisItem) => thisItem is DoorAndWindowBlockRefInfo);
						Dictionary<DoorAndWindowConfigInfo, List<DoorAndWindowBlockRefInfo>> dictionary2 = DoorAndWindowManager.GroupDoorAndWindow(list2.ConvertAll<DoorAndWindowBlockRefInfo>((ICadElement item) => item as DoorAndWindowBlockRefInfo), this.m_lstWindowNumberInfo);
						bool isDisposed4 = quickModelProgressBar.IsDisposed;
						if (isDisposed4)
						{
							this.m_bCancel = true;
						}
						else
						{
							quickModelProgressBar.Dispose();
							bool flag2 = (list == null || list.Count < 1) && (dictionary2 == null || dictionary2.Count < 1) && (dictionary == null || dictionary.Count < 1);
							if (flag2)
							{
								YJKMessageBox.Show("没有符合翻模条件的图元！");
								this.m_bCancel = true;
							}
							else
							{
								QuickModelTransForm quickModelTransForm = new QuickModelTransForm(this.m_doc, list, dictionary2, dictionary);
								bool flag3 = quickModelTransForm.ShowDialog(this.m_handleRevit) == DialogResult.OK;
								if (flag3)
								{
									this.CreateWallRequest(quickModelTransForm.WallGroupInfoes);
									this.CreateColumnRequest(quickModelTransForm.ConfigColumnLoop);
									this.CreateDoorAndWindowRequest(quickModelTransForm.DoorAndWindowConfig);
								}
								else
								{
									this.m_bCancel = true;
								}
							}
						}
					}
				}
			}
		}

		private void CreateWallRequest(List<WallGroupInfo> lstWallGroupInfo)
		{
			bool flag = lstWallGroupInfo == null;
			if (!flag)
			{
				foreach (WallGroupInfo wallGroupInfo in lstWallGroupInfo)
				{
					bool flag2 = !wallGroupInfo.IsTransform;
					if (!flag2)
					{
						double dWallCoreWidth = AssistFunc.mmToFeet((double)wallGroupInfo.WallWidth);
						ElementId wallType = WallManager.GetWallType(this.m_doc, wallGroupInfo.WallType, wallGroupInfo.Useage, dWallCoreWidth);
						bool flag3 = wallType == ElementId.InvalidElementId;
						if (!flag3)
						{
							string useage = wallGroupInfo.Useage;
							double topOffset = AssistFunc.mmToFeet((double)wallGroupInfo.TopOffset);
							foreach (DoubleParaleCurve doubleParaleCurve in wallGroupInfo.ParaleCurves)
							{
								WallRequest wallRequest = new WallRequest();
								wallRequest.IsStruct = (useage.CompareTo("结构墙") == 0);
								wallRequest.TopOffset = topOffset;
								wallRequest.WallTypeId = wallType;
								wallRequest.LocationCurve = doubleParaleCurve.LocationCurve;
								this.m_lstRequest.Add(wallRequest);
							}
						}
					}
				}
			}
		}

		private void CreateColumnRequest(Dictionary<ColumnConfigInfo, List<ColumnLoopInfo>> dicSameConfigColumn)
		{
			ColumnManager.PreLoadDefaultFamily(this.m_doc, true);
			ColumnManager.PreLoadDefaultFamily(this.m_doc, false);
			Dictionary<ColumnConfigInfo, List<ColumnLoopInfo>> dictionary = new Dictionary<ColumnConfigInfo, List<ColumnLoopInfo>>();
			List<ColumnRequest> list = new List<ColumnRequest>();
			foreach (KeyValuePair<ColumnConfigInfo, List<ColumnLoopInfo>> keyValuePair in dicSameConfigColumn)
			{
				ColumnConfigInfo key = keyValuePair.Key;
				bool flag = !key.Rebuild;
				if (!flag)
				{
					dictionary.Add(keyValuePair.Key, keyValuePair.Value);
					foreach (ColumnLoopInfo loopInfo in keyValuePair.Value)
					{
						ColumnRequest item = new ColumnRequest(loopInfo, key);
						list.Add(item);
					}
				}
			}
			bool flag2 = !dictionary.IsEmpty<KeyValuePair<ColumnConfigInfo, List<ColumnLoopInfo>>>();
			if (flag2)
			{
				ColumnFamilySymbolRequest item2 = new ColumnFamilySymbolRequest(dictionary);
				this.m_lstRequest.Add(item2);
				this.m_lstRequest.AddRange(list);
			}
		}

		private void CreateDoorAndWindowRequest(Dictionary<DoorAndWindowConfigInfo, List<DoorAndWindowBlockRefInfo>> dicSameConfigDoorWindow)
		{
			List<DoorAndWindowConfigInfo> list = new List<DoorAndWindowConfigInfo>();
			List<DoorAndWindowRequest> list2 = new List<DoorAndWindowRequest>();
			foreach (KeyValuePair<DoorAndWindowConfigInfo, List<DoorAndWindowBlockRefInfo>> keyValuePair in dicSameConfigDoorWindow)
			{
				DoorAndWindowConfigInfo key = keyValuePair.Key;
				bool flag = !key.Rebuild;
				if (!flag)
				{
					list.Add(key);
					foreach (DoorAndWindowBlockRefInfo blockRef in keyValuePair.Value)
					{
						DoorAndWindowRequest item = new DoorAndWindowRequest(blockRef, key);
						list2.Add(item);
					}
				}
			}
			bool flag2 = !list.IsEmpty<DoorAndWindowConfigInfo>();
			if (flag2)
			{
				DoorAndWindowFamilySymbolRequest item2 = new DoorAndWindowFamilySymbolRequest(list);
				this.m_lstRequest.Add(item2);
				this.m_lstRequest.AddRange(list2);
			}
		}

		private List<CurveInfo> SelectImportDwgCurve(SelecteEntType selectType, string strPrompt, List<string> lstLayerName, List<Category> lstLayerCategory)
		{
			List<CurveInfo> list = new List<CurveInfo>();
			Transaction transaction = new Transaction(this.m_doc);
			transaction.Start("HideLayer");
			for (;;)
			{
				try
				{
					List<CurveInfo> list2 = new List<CurveInfo>();
					bool flag = !this.m_dwgEntitiesSelection.TryPickSameLayerAllCurve(out list2, true, selectType, strPrompt);
					if (flag)
					{
						bool flag2 = false;
						string resultInfo = DwgEntitiesSelectionCommon.GetResultInfo(this.m_dwgEntitiesSelection.Result, out flag2);
						bool flag3 = !flag2;
						if (flag3)
						{
							YJKMessageBox.Show(resultInfo);
							transaction.RollBack();
						}
						break;
					}
					bool flag4 = list2 != null && list2.Count > 0;
					if (flag4)
					{
						string empty = string.Empty;
						Category item = null;
						bool cadElementLayer = RevitCommonFunctions.GetCadElementLayer(list2[0], ref empty, ref item);
						if (cadElementLayer)
						{
							list.AddRange(list2);
							lstLayerName.Add(empty);
							lstLayerCategory.Add(item);
						}
					}
				}
				catch
				{
					break;
				}
			}
			bool flag5 = !transaction.HasEnded();
			if (flag5)
			{
				transaction.Commit();
			}
			return list;
		}

		private List<DoorAndWindowBlockRefInfo> SelectImportDwgBlock(string strPrompt, List<string> lstLayerName, List<Category> lstLayerCategory)
		{
			List<DoorAndWindowBlockRefInfo> list = new List<DoorAndWindowBlockRefInfo>();
			Transaction transaction = new Transaction(this.m_doc);
			transaction.Start("HideLayer");
			for (;;)
			{
				try
				{
					List<DoorAndWindowBlockRefInfo> list2 = new List<DoorAndWindowBlockRefInfo>();
					bool flag = !this.m_dwgEntitiesSelection.TryPickSameLayerBlockRef<DoorAndWindowBlockRefInfo>(out list2, true, strPrompt);
					if (flag)
					{
						bool flag2 = false;
						string resultInfo = DwgEntitiesSelectionCommon.GetResultInfo(this.m_dwgEntitiesSelection.Result, out flag2);
						bool flag3 = !flag2;
						if (flag3)
						{
							YJKMessageBox.Show(resultInfo);
							transaction.RollBack();
						}
						break;
					}
					bool flag4 = list2 != null && list2.Count > 0;
					if (flag4)
					{
						string empty = string.Empty;
						Category item = null;
						bool cadElementLayer = RevitCommonFunctions.GetCadElementLayer(list2[0], ref empty, ref item);
						if (cadElementLayer)
						{
							list.AddRange(list2);
							lstLayerName.Add(empty);
							lstLayerCategory.Add(item);
						}
					}
				}
				catch
				{
					break;
				}
			}
			bool flag5 = !transaction.HasEnded();
			if (flag5)
			{
				transaction.Commit();
			}
			return list;
		}

		private List<TextInfo> SelectImportDwgText(string strPrompt, List<string> lstLayerName, List<Category> lstLayerCategory)
		{
			List<TextInfo> list = new List<TextInfo>();
			Transaction transaction = new Transaction(this.m_doc);
			transaction.Start("HideLayer");
			for (;;)
			{
				try
				{
					List<TextInfo> list2 = new List<TextInfo>();
					bool flag = !this.m_dwgEntitiesSelection.TryPickSameLayerText(out list2, true, strPrompt);
					if (flag)
					{
						bool flag2 = false;
						string resultInfo = DwgEntitiesSelectionCommon.GetResultInfo(this.m_dwgEntitiesSelection.Result, out flag2);
						bool flag3 = !flag2;
						if (flag3)
						{
							YJKMessageBox.Show(resultInfo);
							transaction.RollBack();
						}
						break;
					}
					bool flag4 = list2 != null && list2.Count > 0;
					if (flag4)
					{
						string empty = string.Empty;
						Category item = null;
						bool cadElementLayer = RevitCommonFunctions.GetCadElementLayer(list2[0], ref empty, ref item);
						if (cadElementLayer)
						{
							list.AddRange(list2);
							lstLayerName.Add(empty);
							lstLayerCategory.Add(item);
						}
					}
				}
				catch
				{
					break;
				}
			}
			bool flag5 = !transaction.HasEnded();
			if (flag5)
			{
				transaction.Commit();
			}
			return list;
		}

		private List<CurveInfo> SearchImportDwgCurve(List<string> lstLayerName, SelecteEntType selectType, List<Category> lstLayerCategory)
		{
			List<CurveInfo> list = new List<CurveInfo>();
			for (int i = 0; i < lstLayerName.Count; i++)
			{
				bool flag = list == null || list.Count < 1;
				if (flag)
				{
					lstLayerName.RemoveAt(i);
					i--;
				}
			}
			return list;
		}

		private List<DoorAndWindowBlockRefInfo> SearchImportDwgBlock(List<string> lstLayerName, List<Category> lstLayerCategory)
		{
			List<DoorAndWindowBlockRefInfo> list = new List<DoorAndWindowBlockRefInfo>();
			for (int i = 0; i < lstLayerName.Count; i++)
			{
				bool flag = list == null || list.Count < 1;
				if (flag)
				{
					lstLayerName.RemoveAt(i);
					i--;
				}
			}
			return list;
		}

		private List<TextInfo> SearchImportDwgText(List<string> lstLayerName, List<Category> lstLayerCategory)
		{
			List<TextInfo> list = new List<TextInfo>();
			for (int i = 0; i < lstLayerName.Count; i++)
			{
				bool flag = list == null || list.Count < 1;
				if (flag)
				{
					lstLayerName.RemoveAt(i);
					i--;
				}
			}
			return list;
		}

		public static void CreateCurves(List<Curve> lstCurve, Autodesk.Revit.DB.Document doc)
		{
			CurveArray curveArray = new CurveArray();
			foreach (Curve curve in lstCurve)
			{
				curveArray.Append(curve);
			}
			Transaction transaction = new Transaction(doc);
			transaction.Start("CreateCurves");
			try
			{
				Plane plane = RevitVersionFuncs.CreatePlanByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero);
				SketchPlane sketchPlane = RevitVersionFuncs.NewSketchPlane(doc, plane);
				doc.Create.NewModelCurveArray(curveArray, sketchPlane);
			}
			catch
			{
			}
			transaction.Commit();
		}

		private Document m_doc;

		private List<InputRequest> m_lstRequest;

		private List<CurveInfo> m_lstWallInfo;

		private List<CurveInfo> m_lstColumnInfo;

		private List<DoorAndWindowBlockRefInfo> m_lstWindowInfo;

		private List<TextInfo> m_lstWindowNumberInfo;

		private List<Category> m_lstWallCategory;

		private List<Category> m_lstColumnCategory;

		private List<Category> m_lstWindowCategory;

		private List<Category> m_lstWindowNumberCategory;
	}
}
